//
//  AppDelegate.m
//  JQGeTuiService
//
//  Created by JQZ on 2018/1/18.
//  Copyright © 2018年 JQ. All rights reserved.
//

#import "AppDelegate.h"
#import "JQGeTuiService.h"

/// 个推
#define     kGtAppId           @"Your getui app id"
#define     kGtAppKey          @"Your getui app key"
#define     kGtAppSecret       @"Your getui app secret"

@interface AppDelegate ()<JQGeTuiServiceDelegate>

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    ///------------------------------------------------------------------------------------------┐
    // This file is NOT neccessary. You can use JQSOAppDelegate directly, without any subclasses.│
    ///------------------------------------------------------------------------------------------┘
    // Do something before all other app services
    // ...
    [self initServices:launchOptions];
    
    // JQSOAppDelegate (the super) does not implement -application:didFinishLaunchingWithOptions: actually.
    // It forwards the message to all registered services.
    // You MUST call super to ensure all registered service implementation get called.
    if ([super respondsToSelector:@selector(application:didFinishLaunchingWithOptions:)]) {
        [super application:application didFinishLaunchingWithOptions:launchOptions];
    }
    
    return YES;
}

- (void)initServices:(NSDictionary *)launchOptions
{
    [JQGeTuiService sharedInstance].gtAppId = kGtAppId;
    [JQGeTuiService sharedInstance].gtAppKey = kGtAppKey;
    [JQGeTuiService sharedInstance].gtAppSecret = kGtAppSecret;
    [JQGeTuiService sharedInstance].delegate = self;
}

#pragma mark 消息推送相关处理

/**
 *  @brief  处理个推消息
 */
- (void)GeTuiServiceDidReceiveGeTuiNotification:(NSDictionary *)notification
{
    NSLog(@"[DEBUG]%@",notification[@"payload"]);
    NSLog(@"[DEBUG]－－－－－接收到个推通知------");
}

/**
 *  @brief  处理远程苹果通知
 */
- (void)GeTuiServiceDidReceiveRemoteNotification:(NSDictionary *)notification
{
    NSLog(@"[DEBUG]%@",notification[@"message"]);
    NSLog(@"－－－－－接收到苹果通知------");
}

/**
 *  @brief 获得注册成功时的deviceToken 可以在里面做一些绑定操作
 */
- (void)GeTuiServiceDidReceiveDeviceToken:(NSString *)deviceToken
{
    NSLog(@"[DEBUG]当前deviceToken：%@",deviceToken);
}

/**
 *  @brief 获得个推注册成功时的clientId
 */
- (void)GeTuiServiceDidReceiveGeTuiClientId:(NSString *)clientId
{
    NSLog(@"[DEBUG]个推当前clientId：%@",clientId);
}

@end
